package com.wing.cabinet.controller.app;

import com.wing.cabinet.controller.admin.CellInventoryProductController;
import com.wing.cabinet.controller.admin.CellInventorySpaceController;
import com.wing.cabinet.controller.admin.StorageInventoryProductController;
import com.wing.cabinet.controller.admin.StorageInventorySpaceController;
import com.wing.cabinet.controller.admin.StorageSingleInventoryProductController;
import com.wing.cabinet.controller.admin.UseInventoryUserController;
import com.wing.cabinet.controller.admin.*;
import com.wing.cabinet.model.entity.Cabinet;
import com.wing.cabinet.model.entity.CabinetCargoSpace;
import com.wing.cabinet.model.entity.StorageInventorySpace;
import com.wing.cabinet.model.response.*;
import com.wing.common.utils.PageResult;
import com.wing.order.controller.admin.InventoryProductRecordInController;
import com.wing.order.controller.admin.InventoryProductRecordOutController;
import com.wing.order.controller.admin.MaterialInventoryStatisticsReportController;
import com.wing.order.model.response.CabInventoryProductRecordVO;
import com.wing.product.controller.admin.CancellationMaterialController;
import com.wing.product.model.entity.ProductCategory;
import com.wing.product.model.response.ProductDetailVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@Validated
@Api(value = "App-cab服务无APP类接口管理", tags = "无APP类接口管理")
@RestController("appletController")
@RequestMapping("cabinet/app/applet")
public class AppletController {
    @Autowired
    private InventoryProductRecordInController productRecordInController;
    @Autowired
    private InventoryProductRecordOutController productRecordOutController;
    @Autowired
    private MaterialInventoryStatisticsReportController materialInventoryStatisticsReportController;
    @Autowired
    private CancellationMaterialController cancellationMaterialController;
    @Autowired
    private UseInventoryUserController useInventoryUserController;

    @Autowired
    private UseInventoryLossController useInventoryLossController;

    @Autowired
    private CellInventoryProductController cellInventoryProductController;

    @Autowired
    private CellInventorySpaceController cellInventorySpaceController;

    @Autowired
    private CellInventoryCabinetController cellInventoryCabinetController;

    @Autowired
    private StorageInventorySpaceController storageInventorySpaceController;
    @Autowired
    private StorageInventoryProductController storageInventoryProductController;
    @Autowired
    private StorageSingleInventoryCabinetController singleInventoryCabinetController;
    @Autowired
    private StorageSingleInventoryProductController singleInventoryProductController;

    @GetMapping("/list")
    public void test(){

    }

    @ApiOperation(value = "查询入库记录", notes = "搜索")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "第几页", defaultValue = "1", example = "1", dataType = "Integer", paramType = "query")
            ,@ApiImplicitParam(name = "limit", value = "每页多少条", defaultValue = "10", example = "10", dataType = "Integer", paramType = "query")
            ,@ApiImplicitParam(name = "sort", value="排序字段名", defaultValue = "create_time", example = "create_time", dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "order", value="排序规则(asc:正序, desc:倒序)", defaultValue = "asc", example = "asc", dataType = "String", paramType = "query")
    })
    @GetMapping("/getProductRecordIn")
    public PageResult<CabInventoryProductRecordVO> getProductRecordIn(
            @RequestParam(defaultValue = "1") Integer page
            ,@RequestParam(defaultValue = "10") Integer limit
            ,@RequestParam(defaultValue = "create_time") String sort
            ,@RequestParam(defaultValue = "desc") String order
            ,String skuCode
            ,Long warehouseId
            ,String startCreateTime
            ,String endCreateTime
            ,String query
    ){
        return productRecordInController.list(page, limit, sort, order, skuCode, warehouseId, startCreateTime, endCreateTime,query);
    }

    @ApiOperation(value = "查询出库记录", notes = "搜索")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "第几页", defaultValue = "1", example = "1", dataType = "Integer", paramType = "query")
            ,@ApiImplicitParam(name = "limit", value = "每页多少条", defaultValue = "10", example = "10", dataType = "Integer", paramType = "query")
            ,@ApiImplicitParam(name = "sort", value="排序字段名", defaultValue = "create_time", example = "create_time", dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "order", value="排序规则(asc:正序, desc:倒序)", defaultValue = "asc", example = "asc", dataType = "String", paramType = "query")
    })
    @GetMapping("/getProductRecordOut")
    public PageResult<CabInventoryProductRecordVO> getProductRecordOut(
            @RequestParam(defaultValue = "1") Integer page
            ,@RequestParam(defaultValue = "10") Integer limit
            ,@RequestParam(defaultValue = "create_time") String sort
            ,@RequestParam(defaultValue = "desc") String order
            ,String skuCode
            ,Long warehouseId
            ,String startCreateTime
            ,String endCreateTime
            ,String query
    ){
        return productRecordOutController.list(page, limit, sort, order, skuCode, warehouseId, startCreateTime, endCreateTime,query);
    }

    @ApiOperation(value = "查询物料库存变动", notes = "搜索")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "第几页", defaultValue = "1", example = "1", dataType = "Integer", paramType = "query")
            ,@ApiImplicitParam(name = "limit", value = "每页多少条", defaultValue = "10", example = "10", dataType = "Integer", paramType = "query")
            ,@ApiImplicitParam(name = "sort", value="排序字段名", defaultValue = "create_time", example = "create_time", dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "order", value="排序规则(asc:正序, desc:倒序)", defaultValue = "asc", example = "asc", dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "skuCode", value="物料编号", dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "skuName", value="物料名称", dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "oldSpecCode", value="规格码", dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "startCreateTime", value="开始时间", dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "endCreateTime", value="结束时间", dataType = "String", paramType = "query")
    })
    @GetMapping("/getMaterialInventory")
    public PageResult<CabInventoryProductRecordVO> getMaterialInventory(
            @RequestParam(defaultValue = "1") Integer page
            ,@RequestParam(defaultValue = "10") Integer limit
            ,@RequestParam(defaultValue = "create_time") String sort
            ,@RequestParam(defaultValue = "desc") String order
            ,Long warehouseId
            ,String skuCode
            ,String skuName
            ,String oldSpecCode
            ,String startCreateTime
            ,String endCreateTime
            ,String query
    ){
        return materialInventoryStatisticsReportController.list(page, limit, sort, order, warehouseId, skuCode, skuName, oldSpecCode, startCreateTime, endCreateTime,query);
    }

    @ApiOperation(value = "查询作废物料", notes = "搜索")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "第几页", defaultValue = "1", example = "1", dataType = "Integer", paramType = "query")
            ,@ApiImplicitParam(name = "limit", value = "每页多少条", defaultValue = "10", example = "10", dataType = "Integer", paramType = "query")
            ,@ApiImplicitParam(name = "sort", value="排序字段名", defaultValue = "create_time", example = "create_time", dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "order", value="排序规则(asc:正序, desc:倒序)", defaultValue = "asc", example = "asc", dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "skuCode", value = "商品SKU编码", defaultValue = "", example = "", dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "skuName", value = "商品SKU名称", defaultValue = "", example = "", dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "productName", value = "商品名称", defaultValue = "", example = "", dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "productBrandName", value = "商品品牌名称", defaultValue = "", example = "", dataType = "String", paramType = "query")
    })
    @GetMapping("/getCancellationMaterial")
    public PageResult<ProductDetailVO> getCancellationMaterial(
            @RequestParam(defaultValue = "1") Integer page
            ,@RequestParam(defaultValue = "10") Integer limit
            ,@RequestParam(defaultValue = "id") String sort
            ,@RequestParam(defaultValue = "desc") String order
            ,String skuCode
            ,String skuName
            ,String productName
            ,String productBrandName
            ,String oldSkuCode
            ,String oldSpecCode
            , String startTime
            , String endTime
            , ProductCategory.CategoryType categoryType
            , ProductCategory.Type type
            ,String query
            , Long productTypeId
            , Long productCategoryId
    ){
        return cancellationMaterialController.list(page, limit, sort, order, skuCode, skuName, productName, productBrandName, oldSkuCode, oldSpecCode, startTime, endTime, categoryType, type,query, productTypeId, productCategoryId);
    }

    @ApiOperation(value = "查询未归还记录", notes = "搜索")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "第几页", defaultValue = "1", example = "1", dataType = "Integer", paramType = "query")
            ,@ApiImplicitParam(name = "limit", value = "每页多少条", defaultValue = "10", example = "10", dataType = "Integer", paramType = "query")
            ,@ApiImplicitParam(name = "sort", value="排序字段名", defaultValue = "create_time", example = "create_time", dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "order", value="排序规则(asc:正序, desc:倒序)", defaultValue = "asc", example = "asc", dataType = "String", paramType = "query")
    })
    @GetMapping("/getUseInventory")
    public PageResult<UseInventoryUserVO> getUseInventory(
            @RequestParam(name = "page",defaultValue = "1") Integer page
            ,@RequestParam(name = "limit",defaultValue = "10") Integer limit
            ,@RequestParam(name = "sort",defaultValue = "id") String sort
            ,@RequestParam(name = "order",defaultValue = "desc") String order
            ,String deviceCode
            ,Long productCategoryId
            ,Long productTypeId
            ,String cabCodes
            ,String skuName
            ,String brandName
            ,String typeName
            ,String name
            ,String orderCode
            ,String oldSpecCode
            ,String skuCode
            ,String query
            ,String startTime
            ,String endTime
            ,Long creatorId
            ,String creatorName
            ,String mainCabCode
    ) {
        return useInventoryUserController.list(page, limit, sort, order, deviceCode, productCategoryId, productTypeId, cabCodes, skuName, brandName, typeName, name, orderCode, oldSpecCode, skuCode,query,startTime,endTime,creatorId, creatorName, mainCabCode);
    }

    @ApiOperation(value = "查询所有售刀柜报失", notes = "搜索")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "第几页", defaultValue = "1", example = "1", dataType = "Integer", paramType = "query")
            ,@ApiImplicitParam(name = "limit", value = "每页多少条", defaultValue = "10", example = "10", dataType = "Integer", paramType = "query")
            ,@ApiImplicitParam(name = "sort", value="排序字段名", defaultValue = "create_time", example = "create_time", dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "order", value="排序规则(asc:正序, desc:倒序)", defaultValue = "asc", example = "asc", dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "code", value = "存/取刀任务编号", defaultValue = "", example = "", dataType = "String", paramType = "query")
    })
    @GetMapping("/getUseInventoryLoss")
    public PageResult<UseInventoryInoutVO> getUseInventoryLoss(
            @RequestParam(defaultValue = "1") Integer page
            ,@RequestParam(defaultValue = "10") Integer limit
            ,@RequestParam(defaultValue = "id") String sort
            ,@RequestParam(defaultValue = "desc") String order
            ,String code
            ,String cabCode
            ,String skuCode
            ,String oldSpecCode
            ,String deviceCode
            ,String startTime
            ,String endTime
            ,Long creatorId
            ,Long departmentId
            ,String query
            ,String mainCabCode
    ){
        return useInventoryLossController.list(page, limit, sort, order, code, cabCode, skuCode, oldSpecCode, deviceCode, startTime, endTime, creatorId, departmentId,query,mainCabCode);
    }

    @ApiOperation(value = "查询所有售刀柜产品库存(按产品)", notes = "小程序接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "第几页", defaultValue = "1", example = "1", dataType = "Integer", paramType = "query")
            ,@ApiImplicitParam(name = "limit", value = "每页多少条", defaultValue = "10", example = "10", dataType = "Integer", paramType = "query")
            ,@ApiImplicitParam(name = "sort", value="排序字段名", defaultValue = "create_time", example = "create_time", dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "order", value="排序规则(asc:正序, desc:倒序)", defaultValue = "asc", example = "asc", dataType = "String", paramType = "query")
    })
    @GetMapping("/getCellInventoryProduct")
    public PageResult<CellInventoryProductVO> getCellInventoryProduct(
            @RequestParam(defaultValue = "1") Integer page
            , @RequestParam(defaultValue = "10") Integer limit
            , @RequestParam(defaultValue = "create_time") String sort
            , @RequestParam(defaultValue = "asc") String order
            , String code
            , String skuCode
            , String skuCode4Detail
            , String cabCode
            , String mainCabCode
            , String queryFlag
            , Cabinet.CabinetNature cabinetNature
            ,String oldSpecCode
            ,String query
    ){

        return cellInventoryProductController.list(page, limit, sort, order, code, skuCode, skuCode4Detail, cabCode, mainCabCode, queryFlag, cabinetNature, oldSpecCode,query);
    }

    @ApiOperation(value = "查询所有售刀柜产品货道库存(按货道)", notes = "搜索")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "第几页", defaultValue = "1", example = "1", dataType = "Integer", paramType = "query")
            ,@ApiImplicitParam(name = "limit", value = "每页多少条", defaultValue = "10", example = "10", dataType = "Integer", paramType = "query")
            ,@ApiImplicitParam(name = "sort", value="排序字段名", defaultValue = "create_time", example = "create_time", dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "order", value="排序规则(asc:正序, desc:倒序)", defaultValue = "asc", example = "asc", dataType = "String", paramType = "query")
    })
    @GetMapping("/getCellInventorySpace")
    public PageResult<CellInventorySpaceVO> getCellInventorySpace(
            @RequestParam(defaultValue = "1") Integer page
            , @RequestParam(defaultValue = "10") Integer limit
            , @RequestParam(defaultValue = "create_time") String sort
            , @RequestParam(defaultValue = "asc") String order
            , String code
            , String cabCode
            , String skuCode
            , String skuCode4Detail
            , String spaceCode
            , String mainCabCode
            , String queryFlag
            , Cabinet.CabinetNature cabinetNature
            ,String oldSpecCode
            ,String belongCabinet
            ,String query
    ){
        return cellInventorySpaceController.list(page, limit, sort, order, code, cabCode, skuCode, skuCode4Detail, spaceCode, mainCabCode, queryFlag, cabinetNature, oldSpecCode, belongCabinet,query);
    }

    @ApiOperation(value = "查询所有售刀柜产品库存(按主柜)", notes = "搜索")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "第几页", defaultValue = "1", example = "1", dataType = "Integer", paramType = "query")
            ,@ApiImplicitParam(name = "limit", value = "每页多少条", defaultValue = "10", example = "10", dataType = "Integer", paramType = "query")
            ,@ApiImplicitParam(name = "sort", value="排序字段名", defaultValue = "create_time", example = "create_time", dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "order", value="排序规则(asc:正序, desc:倒序)", defaultValue = "asc", example = "asc", dataType = "String", paramType = "query")
    })
    @GetMapping("/getCellSingleInventoryProduct")
    public PageResult<CellSingleInventoryProductVO> getCellSingleInventoryProduct(
            @RequestParam(defaultValue = "1") Integer page
            , @RequestParam(defaultValue = "10") Integer limit
            , @RequestParam(defaultValue = "create_time") String sort
            , @RequestParam(defaultValue = "asc") String order
            , String code
            , String cabCode
            , String skuCode
            , String skuCode4Detail
            , String spaceCode
            , String mainCabCode
            , String queryFlag
            , Cabinet.CabinetNature cabinetNature
            ,String oldSpecCode
            ,String belongCabinet
            ,String query
    ){
        return cellInventoryCabinetController.list(page, limit, sort, order, code, cabCode, skuCode, skuCode4Detail, spaceCode, mainCabCode, queryFlag, cabinetNature, oldSpecCode, belongCabinet,query);
    }

    @ApiOperation(value = "查询所有暂存柜产品货道库存(按货位)", notes = "搜索")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "第几页", defaultValue = "1", example = "1", dataType = "Integer", paramType = "query")
            ,@ApiImplicitParam(name = "limit", value = "每页多少条", defaultValue = "10", example = "10", dataType = "Integer", paramType = "query")
            ,@ApiImplicitParam(name = "sort", value="排序字段名", defaultValue = "create_time", example = "create_time", dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "order", value="排序规则(asc:正序, desc:倒序)", defaultValue = "asc", example = "asc", dataType = "String", paramType = "query")
    })
    @GetMapping("/getStorageInventorySpace")
    public PageResult<StorageInventorySpaceVO> getStorageInventorySpace(
            @RequestParam(defaultValue = "1") Integer page
            , @RequestParam(defaultValue = "10") Integer limit
            , @RequestParam(defaultValue = "create_time") String sort
            , @RequestParam(defaultValue = "asc") String order
            , String code
            , String cabCode
            , String spaceCode
            , String skuCode
            , String cabCode4Detail
            , String spaceCode4Detail
            , String skuCode4Detail
            , StorageInventorySpace.BusinessType businessType
            , CabinetCargoSpace.CheckStatus checkStatus
            ,String oldSpecCode
            ,String belongCabinet
            ,String cabinetCode
            ,Long id
            ,String menu
            ,String query
    ){
        return storageInventorySpaceController.list(page, limit, sort, order, code, cabCode, spaceCode, skuCode, cabCode4Detail, spaceCode4Detail, skuCode4Detail, businessType, checkStatus, oldSpecCode, belongCabinet, cabinetCode, id, menu,query);
    }

    @ApiOperation(value = "查询所有暂存柜产品库存(按产品)", notes = "搜索")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "第几页", defaultValue = "1", example = "1", dataType = "Integer", paramType = "query")
            ,@ApiImplicitParam(name = "limit", value = "每页多少条", defaultValue = "10", example = "10", dataType = "Integer", paramType = "query")
            ,@ApiImplicitParam(name = "sort", value="排序字段名", defaultValue = "create_time", example = "create_time", dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "order", value="排序规则(asc:正序, desc:倒序)", defaultValue = "asc", example = "asc", dataType = "String", paramType = "query")
    })
    @GetMapping("/getStorageInventoryProduct")
    public PageResult<StorageInventoryProductVO> getStorageInventoryProduct(
            @RequestParam(defaultValue = "1") Integer page
            ,@RequestParam(defaultValue = "10") Integer limit
            ,@RequestParam(defaultValue = "create_time") String sort
            ,@RequestParam(defaultValue = "asc") String order
            ,String code
            ,String skuCode
            ,String skuCode4Detail
            ,String oldSpecCode
            ,String query
    ){
        return storageInventoryProductController.list(page, limit, sort, order, code, skuCode, skuCode4Detail, oldSpecCode,query);
    }

    @ApiOperation(value = "查询所有暂存柜产品库存(按主柜)", notes = "搜索")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "第几页", defaultValue = "1", example = "1", dataType = "Integer", paramType = "query")
            ,@ApiImplicitParam(name = "limit", value = "每页多少条", defaultValue = "10", example = "10", dataType = "Integer", paramType = "query")
            ,@ApiImplicitParam(name = "sort", value="排序字段名", defaultValue = "create_time", example = "create_time", dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "order", value="排序规则(asc:正序, desc:倒序)", defaultValue = "asc", example = "asc", dataType = "String", paramType = "query")
    })
    @GetMapping("/getStorageSingleInventoryCabinet")
    public PageResult<StorageSingleInventoryProductVO> getStorageSingleInventoryCabinet(
            @RequestParam(defaultValue = "1") Integer page
            , @RequestParam(defaultValue = "10") Integer limit
            , @RequestParam(defaultValue = "create_time") String sort
            , @RequestParam(defaultValue = "asc") String order
            , String code
            , String cabCode
            , String skuCode
            , Long productType
            ,Long productBrandId
            ,String oldSpecCode
            ,String query
    ){
        return singleInventoryCabinetController.list(page, limit, sort, order, code, cabCode, skuCode, productType, productBrandId, oldSpecCode,query);
    }

    @ApiOperation(value = "查询所有暂存柜产品库存(按刀柜)", notes = "搜索")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "第几页", defaultValue = "1", example = "1", dataType = "Integer", paramType = "query")
            ,@ApiImplicitParam(name = "limit", value = "每页多少条", defaultValue = "10", example = "10", dataType = "Integer", paramType = "query")
            ,@ApiImplicitParam(name = "sort", value="排序字段名", defaultValue = "create_time", example = "create_time", dataType = "String", paramType = "query")
            ,@ApiImplicitParam(name = "order", value="排序规则(asc:正序, desc:倒序)", defaultValue = "asc", example = "asc", dataType = "String", paramType = "query")
    })
    @GetMapping("/getStorageSingleInventoryProduct")
    public PageResult<StorageSingleInventoryProductVO> getStorageSingleInventoryProduct(
            @RequestParam(defaultValue = "1") Integer page
            , @RequestParam(defaultValue = "10") Integer limit
            , @RequestParam(defaultValue = "create_time") String sort
            , @RequestParam(defaultValue = "asc") String order
            , String code
            , String cabCode
            , String skuCode
            , Long productType
            ,Long productBrandId
            ,String oldSpecCode
            ,String query
    ){
        return singleInventoryProductController.list(page, limit, sort, order, code, cabCode, skuCode, productType, productBrandId, oldSpecCode,query);
    }

}
